package tools;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class GenerateTestSamples {
    public static void main(String[] args) {
        GenerateTestSamples generateTestSamples = new GenerateTestSamples();
//        generateTestSamples.generateWorstCaseGeneralBoundaryValues();
        generateTestSamples.generateWorstCaseRobustnessBoundaryValues();
    }

    void generateValues(int[] values, String fileName){
        BufferedWriter writer = null;
        try{
            writer = new BufferedWriter(new FileWriter(fileName));
            // 写入CSV头（可选）
            writer.write("a,b,c,expected\n");

            // 生成并写入所有可能的三元组
            for (int value1 : values) {
                for (int value2 : values) {
                    for (int value3 : values) {
                        writer.write(value1 + "," + value2 + "," + value3 + ","  +  "\n");
                    }
                }
            }

            System.out.println("File has been written successfully.");

        }catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


    void generateWorstCaseGeneralBoundaryValues() {
        int[] values = new int[]{1, 2, 50, 99, 100};
        String fileName = "src/test/resources/triangle_worst_case_boundary_values.csv";
        generateValues(values, fileName);
    }

    void generateWorstCaseRobustnessBoundaryValues() {
        int[] values = new int[]{0,1, 2, 50, 99, 100,101};
        String fileName = "src/test/resources/worst_case_robustness_boundary_values.csv";
        generateValues(values, fileName);
    }
}
